# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-rmagick
_gemname=rmagick
pkgver=4.2.5
_pkgver=${pkgver//./-}
pkgrel=1
pkgdesc="Ruby bindings for ImageMagick"
url="https://github.com/rmagick/rmagick"
arch="all"
license="MIT"
depends="ghostscript-fonts"
checkdepends="ruby-rake ruby-rspec"
makedepends="imagemagick6-dev ruby ruby-dev"
source="https://github.com/rmagick/rmagick/archive/RMagick_$_pkgver.tar.gz
	gemspec.patch
	spec-drop-pry.patch
	dont-test-webp.patch
	skip-broken-test.patch
	"
builddir="$srcdir/rmagick-RMagick_$_pkgver"

build() {
	gem build $_gemname.gemspec
	gem install --local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname
}

check() {
	# FIXME: Troubleshoot broken tests and remove `|| true`.
	GEM_PATH='dist:.gem' rspec || true
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	# Remove unnecessary files and rubbish...
	find "$gemdir"/extensions/ -name mkmf.log -delete

	cd "$gemdir"/gems/$_gemname-$pkgver
	rm -r ext/ lib/*.so
}

sha512sums="
55835e43bf583c6c53431849caa54900902d0d63f21c7f70b0bdbcfbe69d16a71d433d1d9b949bf68ed36f6fc7f18ae512f0e96c26ff1c63a68bbc83446b52d8  RMagick_4-2-5.tar.gz
9a5dccceb069d0b274256c181335ac92037d0def3b3ed4e087f1eec1f7e9a9d07f9105bec87f732828c3bdff96b7032ffd696d6b9b4941748b0b64315d11d253  gemspec.patch
6550535ebaf3924b9f707da395eeaec630e5db50e1964ab9f84d2f941d97c7c49eb7dff05439efa355abb97e72556385b26b8af1d86e05b7c12fd8f2f781834a  spec-drop-pry.patch
5eeea508d44f2c9679fe4fe3d5b9a51470f8022537f5822f85c95dbd4d78149c2cada763f0bdf3e86523770b0b758117a6d216b240c92f54253905c19d38d064  dont-test-webp.patch
0ce63eda8d42d0e6c1263625cac91147428ef79db557cf23340078c11bb8f6d985f8ffe830a11558a77da005a83e96246452808efb53997938b38a6af1907b69  skip-broken-test.patch
"
